<template>
  <el-container>
    <el-header>
      <el-page-header @back="back">
        <template slot="title">
          <h4></h4>
        </template>
        <template slot="content">
          <h4 style="font-weight:bold;font-size:14px;">
            [{{ logItem.method }}] ---> {{ logItem.raw }}
          </h4>
        </template>
      </el-page-header>
    </el-header>
    <el-main>
      <el-container>
        <el-header style="height: 80px;">
          <el-form :model="logItem" label-width="100px">
            <el-row>
              <el-col :span="8">
                <el-form-item label="记录ID">
                  <el-input v-model="logItem.logId" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="http状态码">
                  <el-input v-model="logItem.status" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="主机">
                  <el-input v-model="logItem.host" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="记录时间">
                  <el-input v-model="logItem.logDate" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="错误码">
                  <el-input v-model="logItem.errCode" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="客端IP">
                  <el-input v-model="logItem.clientIp" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-header>
        <el-main>
          <el-tabs v-model="activeName" @tab-click="tabClick" tab-position="left">
            <el-tab-pane label="请求内容" name="requestBody">
              <mf-monacoEditor ref="requestBody" v-model="logItem.request" language="json" theme="vs-dark" readOnly ></mf-monacoEditor>
            </el-tab-pane>
            <el-tab-pane label="请求头" name="requestHeader">
              <mf-monacoEditor ref="requestHeader" :value="logItem.requestHeader" language="json" theme="vs-dark" readOnly ></mf-monacoEditor>
            </el-tab-pane>
            <el-tab-pane label="请求cookie" name="requestCookies">
              <mf-monacoEditor ref="requestCookies" :value="logItem.requestCookies" language="json" theme="vs-dark" readOnly ></mf-monacoEditor>
            </el-tab-pane>
            <el-tab-pane label="异常描述" name="exception">
              <mf-monacoEditor ref="exception" :value="logItem.exception" language="json" theme="vs-dark" readOnly ></mf-monacoEditor>
            </el-tab-pane>
          </el-tabs>
        </el-main>
      </el-container>

    </el-main>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      activeName: 'requestBody',
      logItem:{
      }
    }
  },
  mounted() {
    let id = this.$route.params.id;
    this.$service.data.objectQuery({routeData:{name:'getErrorLog'}, params: {logId:id}}).then(r => {
      this.logItem = r.data;
      this.$nextTick(() => {
        this.$refs[this.activeName].layout();
      });
    });
  },
  methods: {
    back(){
      this.$router.push({name:'errorLog'})
    },
    tabClick(tab, event){

      this.$nextTick(() => {
        this.$refs[this.activeName].layout();
      });
    }
  }
}
</script>
